//HDU 1724
#include <bits/stdc++.h>

using namespace std;

const double eps=1e-9;
double a,b;

inline int dcmp(const double &d){if(fabs(d)<eps) return 0;return d>0?1:-1;}

struct cmp{
    inline const bool operator ()(const double &x,const double &y) const{return dcmp(x-y)<0;}
};

inline double f(const double &x){
    return b/a*sqrt(a*a-x*x);
}

inline double simpson(const double &a,const double &b){
    double c=(a+b)/2,delta;
    delta=c-a;
    return delta/3*(f(a)+f(b)+4*f(c));
}

double asr(const double &a,const double &b,const double &t){
    double l,r,c;
    c=(a+b)/2;
    l=simpson(a,c);r=simpson(c,b);
    if(fabs(l+r-t)<eps) return l+r;
    else return asr(a,c,l)+asr(c,b,r);
}

inline int read(){
    char c;bool f=0;int r;
    for(c=getchar();c>'9'||c<'0';c=getchar()) if(c=='-') f=1;
    for(r=0;c<='9'&&c>='0';c=getchar()) r=r*10+c-'0';
    if(f) return -r;
    else return r;
}

int main(){
    int T;

    T=read();
    while(T--){
        int l,r;
        a=read();b=read();l=read();r=read();
        printf("%.3f\n",2*asr(l,r,simpson(l,r)));
    }
}
